<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.ahp.bean.User"%>
<%@ include file="../include/common.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<%=path %>/js/jquery-1.3.2.js"></script>
<link rel="stylesheet" href="<%=path%>/style/style_manage.css" type="text/css"></link>
<title>添加用户</title>
<script type="text/javascript">
submitForm = function(){
	var name = $("#loginName").val();
	if($("#password").val()== null || $("#password").val().length<6 || $("#password").val().length >12 || $("#password").val() != $("#repassword").val()){
		$("#result").text("请确认两次输入的用户名相等，并且长度为6-12之间");
		return false;
	}
	if(name==null || name.length <= 3){
		$("#result").text("请填写用户名");
		return false;
	}
	$("#result").text("");
	return checkUserLoginName();
}
checkUserLoginName = function(){
	$.ajax({type:"POST",
		url:"<%=path%>/user/checkUser.action",
		data:{"user.loginName":$("#loginName").val(),d:new Date().getMilliseconds()},
		async:false,
		success:function(data){
			if(data=="have"){
				$("#result").text("登录名已经存在，请尝试新的用户名");
				return false;
			}else{
				$("#myform").submit();
				return true;
			}
		}
	});
}
</script>
</head>
<body>
<div id="management">
<h1 style="position: relative;">添加评估对象</h1>
	<div id="result" style="color:red;"></div>
	<form action="<%=path %>/user/addUser.action" method="post" id="myform">
		<table width="90%">
			<tr><td width="40%" align="right"><label for="loginName">登录名：</label></td><td><input type="text" value="" id="loginName" name="user.loginName"/></td></tr>
			<tr><td align="right"><label for="password">密码：</label></td><td><input type="password" value="" id="password" name="user.password"/></td></tr>
			<tr><td align="right"><label for="repassword">确认密码：</label></td><td><input type="password" value="" id="repassword" name="user.repassword"/></td></tr>
			<tr><td align="right"><label for="trueName">真实姓名：</label></td><td><input type="text" value="" id="trueName" name="user.trueName"/></td></tr>
			<tr><td align="right">性别：</td>
				<td>
					<input type="radio" checked="checked" value="<%=User.SEX_MALE %>" id="<%=User.SEX_MALE %>" name="user.sex"/><label for="<%=User.SEX_MALE %>">男</label>
					<input type="radio" value="<%=User.SES_FEMALE %>" id="<%=User.SES_FEMALE %>" name="user.sex"/><label for="<%=User.SES_FEMALE %>">女</label>
				</td>
			</tr>
			<tr><td align="right"><label for="company">公司：</label></td><td><input type="text" value="" id="company" name="user.company"/></td></tr>
			<tr><td align="right"><label for="headship">职务：</label></td><td><input type="text" value="" id="headship" name="user.headship"/></td></tr>
			<tr><td align="right"><label for="phone">电话：</label></td><td><input type="text" value="" id="phone" name="user.phone"/></td></tr>
			<tr><td align="right"><label for="email">邮箱：</label></td><td><input type="text" value="" id="email" name="user.email"/></td></tr>
			<tr><td align="right">用户类型：</td>
				<td><input type="radio" checked="checked" value="<%=User.USER_TYPE %>" id="<%=User.USER_TYPE %>" name="user.type"/><label for="<%=User.USER_TYPE %>">评估员</label>
					<input type="radio" value="<%=User.MANAGER_TYPE %>" id="<%=User.MANAGER_TYPE %>" name="user.type"/><label for="<%=User.MANAGER_TYPE %>">管理员</label>
				</td>
			</tr>
			<tr><td colspan="2" align="center"><input type="button" value="注册" onclick="this.disable=true;return submitForm();"/></td></tr>
		</table>
	</form>
</div>
</body>
</html>